package com.hr.LandR.service.impl;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.hr.LandR.mapper.LeadershipRelationshipMapper;
import com.hr.LandR.domain.LeadershipRelationship;
import com.hr.LandR.service.ILeadershipRelationshipService;

/**
 * 负责人关系表Service业务层处理
 * 
 * @author guan
 * @date 2024-08-01
 */
@Service
public class LeadershipRelationshipServiceImpl implements ILeadershipRelationshipService 
{
    @Autowired
    private LeadershipRelationshipMapper leadershipRelationshipMapper;

    /**
     * 查询负责人关系表
     * 
     * @param useridSubordinate 负责人关系表主键
     * @return 负责人关系表
     */
    @Override
    public LeadershipRelationship selectLeadershipRelationshipByUseridSubordinate(Long useridSubordinate)
    {
        return leadershipRelationshipMapper.selectLeadershipRelationshipByUseridSubordinate(useridSubordinate);
    }

    /**
     * 查询负责人关系表列表
     * 
     * @param leadershipRelationship 负责人关系表
     * @return 负责人关系表
     */
    @Override
    public List<LeadershipRelationship> selectLeadershipRelationshipList(LeadershipRelationship leadershipRelationship)
    {
        return leadershipRelationshipMapper.selectLeadershipRelationshipList(leadershipRelationship);
    }

    /**
     * 新增负责人关系表
     * 
     * @param leadershipRelationship 负责人关系表
     * @return 结果
     */
    @Override
    public int insertLeadershipRelationship(LeadershipRelationship leadershipRelationship)
    {
        return leadershipRelationshipMapper.insertLeadershipRelationship(leadershipRelationship);
    }

//    /**
//     * 修改负责人关系表
//     *
//     * @param useridSubordinate,useridLeader 负责人关系表
//     * @return 结果
//     */
//    @Override
//    public int updateLeadershipRelationship(Long useridSubordinate,Long useridLeader)
//    {
//        return leadershipRelationshipMapper.updateLeadershipRelationship(useridSubordinate,useridLeader);
//    }

    /**
     * 批量删除负责人关系表
     * 
     * @param useridSubordinates 需要删除的负责人关系表主键
     * @return 结果
     */
    @Override
    public int deleteLeadershipRelationshipByUseridSubordinates(Long[] useridSubordinates)
    {
        return leadershipRelationshipMapper.deleteLeadershipRelationshipByUseridSubordinates(useridSubordinates);
    }

    /**
     * 删除负责人关系表信息
     * 
     * @param useridSubordinate 负责人关系表主键
     * @return 结果
     */
    @Override
    public int deleteLeadershipRelationshipByUseridSubordinate(Long useridSubordinate)
    {
        return leadershipRelationshipMapper.deleteLeadershipRelationshipByUseridSubordinate(useridSubordinate);
    }


    /**
     * 查询用户上下级
     * @param userId
     * @return
     */
    @Override
    public LeadershipRelationship showLeadershipRelationship(Long userId) {
        String leader = leadershipRelationshipMapper.selectLeadership(userId);
        List<String> relations = leadershipRelationshipMapper.selectRelationships(userId);
        LeadershipRelationship l = new LeadershipRelationship(null, null);
        l.setLeaderNickName(leader);
        l.setSubordinateNickName(relations);
        return l;
    }
}
